//
//  TXPAFNetworkingBlock.m
//  StayAwhile
//
//  Created by dllo on 16/1/26.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "TXPAFNetworkingBlock.h"
@implementation TXPAFNetworkingBlock

+ (void)PostAFNURLWithString:(NSString *)url Body:(NSDictionary *)body Cookie:(NSString *)cookie resultBlock:(PostAFNBlockResult)resultBlcok errorBlock:(PostAFNBlockError)errorBlock{
    
    AFHTTPRequestOperationManager *netManager = [AFHTTPRequestOperationManager manager];
    
    //抓到的接口如果有Cookie并且没有Cookie无法正常请求数据的话需要写这句
    //要是不用Cookie的话可以把这句删掉,函数也可以不要这个参数
    [netManager.requestSerializer setValue:cookie forHTTPHeaderField:@"Cookie"];
    
    
    netManager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",@"application/x-javascript",nil];
    [netManager POST:url parameters:body success:^(AFHTTPRequestOperation *operation, id responseObject) {
        resultBlcok(responseObject);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        errorBlock(error);
    }];
    
}


@end
